﻿<Application
    x:Class="FacebookLoginSimulator.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone">

    <!--Application Resources-->
    <Application.Resources>
        <SolidColorBrush x:Key="FacebookBlue"
                         Color="#FF3B5C9A" />
        <SolidColorBrush x:Key="DarkFacebookBlueBrush"
                         Color="#FF29406B" />
        <Style x:Key="DefaultButtonStyle"
               TargetType="Button">
            <Setter Property="Background"
                    Value="Transparent" />
            <Setter Property="BorderBrush"
                    Value="{StaticResource PhoneForegroundBrush}" />
            <Setter Property="Foreground"
                    Value="{StaticResource PhoneForegroundBrush}" />
            <Setter Property="BorderThickness"
                    Value="{StaticResource PhoneBorderThickness}" />
            <Setter Property="FontFamily"
                    Value="{StaticResource PhoneFontFamilySemiBold}" />
            <Setter Property="FontSize"
                    Value="{StaticResource PhoneFontSizeMedium}" />
            <Setter Property="Padding"
                    Value="10,5,10,6" />
            <Setter Property="HorizontalAlignment"
                    Value="Left"/>
            <Setter Property="Background"
                    Value="{StaticResource DarkFacebookBlueBrush}"/>
            <Setter Property="Foreground"
                    Value="White"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid Background="Transparent">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal" />
                                    <VisualState x:Name="MouseOver" />
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"
                                                                           Storyboard.TargetName="ContentContainer">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <SolidColorBrush Color="Black" />
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"
                                                                           Storyboard.TargetName="ButtonBackground">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <SolidColorBrush Color="White" />
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush)"
                                                                           Storyboard.TargetName="ButtonBackground">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <SolidColorBrush Color="White" />
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"
                                                                           Storyboard.TargetName="ContentContainer">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="{StaticResource PhoneDisabledBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"
                                                                           Storyboard.TargetName="ButtonBackground">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Transparent" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStates" />
                            </VisualStateManager.VisualStateGroups>
                            <Border x:Name="ButtonBackground"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    Background="{TemplateBinding Background}"
                                    CornerRadius="0"
                                    Margin="{StaticResource PhoneTouchTargetOverhang}">
                                <ContentControl x:Name="ContentContainer"
                                                ContentTemplate="{TemplateBinding ContentTemplate}"
                                                Content="{TemplateBinding Content}"
                                                Foreground="{TemplateBinding Foreground}"
                                                HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                Padding="{TemplateBinding Padding}"
                                                VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
        <Style x:Key="DefaultTextBoxStyle"
               TargetType="TextBox">
            <Setter Property="FontFamily"
                    Value="{StaticResource PhoneFontFamilyNormal}" />
            <Setter Property="FontSize"
                    Value="{StaticResource PhoneFontSizeMediumLarge}" />
            <Setter Property="Background"
                    Value="{StaticResource PhoneTextBoxBrush}" />
            <Setter Property="Foreground"
                    Value="{StaticResource PhoneTextBoxForegroundBrush}" />
            <Setter Property="BorderBrush"
                    Value="{StaticResource PhoneTextBoxBrush}" />
            <Setter Property="SelectionBackground"
                    Value="{StaticResource PhoneAccentBrush}" />
            <Setter Property="SelectionForeground"
                    Value="{StaticResource PhoneTextBoxSelectionForegroundBrush}" />
            <Setter Property="BorderThickness"
                    Value="{StaticResource PhoneBorderThickness}" />
            <Setter Property="Padding"
                    Value="2" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="TextBox">
                        <Grid Background="Transparent">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal" />
                                    <VisualState x:Name="MouseOver" />
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"
                                                                           Storyboard.TargetName="MainBorder">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Transparent" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush"
                                                                           Storyboard.TargetName="MainBorder">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="{StaticResource PhoneDisabledBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"
                                                                           Storyboard.TargetName="ContentElement">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="{StaticResource PhoneDisabledBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="ReadOnly">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="MainBorder">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Collapsed</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="ReadonlyBorder">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"
                                                                           Storyboard.TargetName="ReadonlyBorder">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="{StaticResource PhoneTextBoxBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush"
                                                                           Storyboard.TargetName="ReadonlyBorder">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="{StaticResource PhoneTextBoxBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"
                                                                           Storyboard.TargetName="ContentElement">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="{StaticResource PhoneTextBoxReadOnlyBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStates">
                                    <VisualState x:Name="Focused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"
                                                                           Storyboard.TargetName="MainBorder">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="{StaticResource PhoneButtonBasePressedForegroundBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush"
                                                                           Storyboard.TargetName="MainBorder">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="{StaticResource DarkFacebookBlueBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Unfocused" />
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="ValidationStates" />
                            </VisualStateManager.VisualStateGroups>
                            <Border x:Name="MainBorder"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    Background="White"
                                    Margin="{StaticResource PhoneTouchTargetOverhang}" />
                            <Border x:Name="ReadonlyBorder"
                                    BorderBrush="{StaticResource PhoneDisabledBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    Background="Transparent"
                                    Margin="{StaticResource PhoneTouchTargetOverhang}"
                                    Visibility="Collapsed" />
                            <Border BorderBrush="Transparent"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    Background="Transparent"
                                    Margin="{StaticResource PhoneTouchTargetOverhang}">
                                <ContentControl x:Name="ContentElement"
                                                BorderThickness="0"
                                                HorizontalContentAlignment="Stretch"
                                                Margin="{StaticResource PhoneTextBoxInnerMargin}"
                                                Padding="{TemplateBinding Padding}"
                                                VerticalContentAlignment="Stretch" />
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <ControlTemplate x:Key="PhoneDisabledPasswordBoxTemplate"
                         TargetType="PasswordBox">
            <Border x:Name="ContentElement"
                    BorderThickness="0"
                    Margin="{StaticResource PhonePasswordBoxInnerMargin}"
                    Padding="{TemplateBinding Padding}" />
        </ControlTemplate>
    </Application.Resources>

    <Application.ApplicationLifetimeObjects>
        <!--Required object that handles lifetime events for the application-->
        <shell:PhoneApplicationService
            Launching="Application_Launching" Closing="Application_Closing"
            Activated="Application_Activated" Deactivated="Application_Deactivated"/>
    </Application.ApplicationLifetimeObjects>

</Application>